//
//  YCMainViewController.swift
//  swift微博
//
//  Created by 姚伟聪 on 15/12/15.
//  Copyright © 2015年 姚伟聪. All rights reserved.
//

import UIKit
import SDWebImage

class YCMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
//        tabBar.tintColor = UIColor.orangeColor()
        let homeController = YCHomeViewController()
        addChildVC(homeController, title: "首页", imageName: "tabbar_home")
        let discoveryController = YCDiscoveryViewController()
        addChildVC(discoveryController, title: "发现", imageName: "tabbar_discover")
       
        let messageController = YCMessageViewController()
         addChildVC(messageController, title: "消息", imageName: "tabbar_message_center")
       
        let profileController = YCProfileViewController()
         addChildVC(profileController, title: "我", imageName: "tabbar_profile")
        
        setValue(YCTabBar(), forKey: "TabBar")
        
    }

    func addChildVC(childVC: UIViewController,title: String,imageName: String) ->Void {
        
        childVC.title = title
        childVC.tabBarItem.image = UIImage(named: imageName)
        
        childVC.tabBarItem.selectedImage = UIImage(named: imageName + "_highlighted")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        childVC.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: UIControlState.Selected)
        
        let nav = UINavigationController(rootViewController: childVC)
        addChildViewController(nav)
        
        
    
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
